"""
1.学习目标
    掌握page类的封装方法
2.操作步骤
    2.1 page.py文件继承Base类
    2.2 封装表现层
    2.3 封装操作层

3.需求
    对ECShop登录页面进行封装
4. 总结
"""
from common.base import Base
from common.base import open_browser

register_url="http://ecshop.itsoso.cn/user.php?act=register"

class RegisterPage(Base):

   username_loc = ("name","username")#用户名
   email_loc = ("name","email")#邮箱
   password_loc = ("name","password")#密码
   notarize_password_loc=("name","confirm_password")#确认密码
   tel_loc = ("name","extend_field5")#电话
   confirm_password_loc = ("name","sel_question")#密码提示
   password_answer_loc = ("name","passwd_answer")#密码问题答案
   look_over_loc= ("name","agreement")#我已经看过
   login_loc = ("name","Submit")#注册
   log_in_loc = ("link text","我已有账号，我要登录")#我已经有账号 要登录
   forget_the_password = ("link text","您忘记密码了吗？")#忘记密码了

   def input_username(self, username):
       '''输入用户名'''
       self.send_keys(self.username_loc, username)


   def input_email(self, email):
       '''输入邮箱'''
       self.send_keys(self.email_loc, email)

   def input_password(self,password):
       '''输入密码'''
       self.send_keys(self.password_loc,password)
   def input_affirm_password(self,text):
       '''确认密码'''
       self.send_keys(self.notarize_password_loc,text)
   def input_tel(self,tel):
       '''输入电话'''
       self.send_keys(self.tel_loc,tel)

   def slect_password_hint(self):

        self.random_choice_select(self.confirm_password_loc)
   def input_password3(self,text):
       '''输入密码'''
       self.send_keys(self.password_answer_loc,text)
   def click_look(self):
       '''已经看过了'''
       self.click(self.look_over_loc)
   def click_login(self):

       '''注册'''
       self.click(self.login_loc)
   def click_log_in(self):
       '''有账号要登录'''
       self.click(self.log_in_loc)
   def clik_forget_password(self):
       '''忘记密码'''
       self.click(self.forget_the_password)

if __name__ == '__main__':
    driver=open_browser()
    login=RegisterPage(driver)
    login.open_url(register_url)
    # login.input_username("130")
    # login.input_email("1140@qq.com")
    # login.input_password("165")
    # login.input_affirm_password("165")
    # login.input_tel("6151")
    login.slect_password_hint()
    login.input_password3("哈哈哈")

    login.close_browser()
    # login.click_log_in()

